1
general::
Behave with respect to, treat, as in John was determined to do well by his children. This idiom was first recorded about 1175.
American Heritage Idioms
2
general::
Phrase(s): do somehow by someone
to treat someone in a particular manner. (Do not confuse this with a passive construction. The someone is not the actor but the object.) • Tom did all right by Ann when he brought her red roses. • I did badly by Tom. I fired him without good reason.
McGrawhill's American Idioms And Phrasal Verbs